<?php
include_once '../inc/config.inc.php';
include_once '../inc/mysqli.inc.php';
include_once '../inc/tool.inc.php';
$link=connect();
if(!$memberid=is_login($link)){
    $url=urlencode("$_SERVER[REQUEST_URI]");
    skip("login.php?url={$url}",'error','请登陆之后再进行发帖！');
}
if(!isset($_GET['id'])||!is_numeric($_GET['id'])||$_GET['id']<1){
    skip('index.php','error','id参数不合法！ ');
}
$queryt="select *from content where id={$_GET['id']}";
$resultt=execute($link,$queryt);
if(mysqli_num_rows($resultt)!=1){
    skip('index.php','error','id参数不合法！ ');
}
$datat=mysqli_fetch_assoc($resultt);
$datat=dehtml($datat);
$datat=tonl2br($datat);

if(isset($_POST['submit'])){
    $_POST=tosqlstring($link,$_POST);
include_once 'inc/checkPublish.php';
$query="update content set cmid={$_POST['cmid']},title='{$_POST['title']}',content='{$_POST['content']}',time=now() where id={$_GET['id']}";
$result=execute($link,$query);
if(mysqli_affected_rows($link)==1){
    skip("member.php",'ok','修改成功！ ');
  }else{
    skip("$_SERVER[REQUEST_URI]",'error','修改失败，请重试！ ');
  }
}







$template='帖子修改';
include_once 'inc/header.inc.php';
?>



        <div class="pbmain">
            <div class="wrap">
                <h2 class="top_dir">
                    <a href="index.php">首页</a>
                    &gt;&nbsp;<a href="member.php">会员中心</a>
                </h2>
                <div class="content">
                    <form method="post">
                        <select name="cmid">
                            <option>请选择一个板块</option>
                            <?php
                            $queryf="select *from fatherModule order by sort desc";
                            $resultf=execute($link,$queryf);
                            while($dataf=mysqli_fetch_assoc($resultf)){
                                echo "<optgroup label='{$dataf['moduleName']}'>";
                                $query="select *from childModule where referid={$dataf['id']}";
                                $result=execute($link,$query);
                                while($data=mysqli_fetch_assoc($result)){
                                    if($data['id']==$datat['cmid']){
                                        echo "<option value='$data[id]' selected='selected' >{$data['moduleName']}</option>";
                                    }else{
                                        echo "<option value='$data[id]' >{$data['moduleName']}</option>";
                                    }
                                    
                                }
                                echo "</optgroup>";
                            }

                            ?>

                        </select>
                        <input type="text" value="<?php echo $datat['title'];?>" name="title" class="title">
                        <textarea name="content" class="text_part" ><?php echo $datat['content'];?></textarea>
                        <input type="submit" name="submit" value="修改" class="nsubmit">
                    </form>
                </div>
            </div>
        </div>
    
        



 <?php
include_once 'inc/footer.inc.php';
?>